﻿using System.Runtime.InteropServices;
using Base.FileService.Interface;
using WeDonekRpc.Client.Attr;
using WeDonekRpc.Client.Interface;
using WeDonekRpc.Helper.Config;

namespace Base.FileService.Config
{
    [ClassLifetimeAttr(ClassLifetimeType.SingleInstance)]
    internal class PdfFileConfig : IPdfFileConfig
    {
        public PdfFileConfig ( ISysConfig config )
        {
            IConfigSection section = config.GetSection("pdfFile");
            section.AddRefreshEvent(this._Refresh);
        }

        private void _Refresh ( IConfigSection section, string name )
        {
            this.AllowExtension = section.GetValue("AllowExtension", new string[] { ".jpg", ".png", ".doc", ".docx", ".xlsx", ".ppt", ".pptx", ".xls", ".wps" });
            string def = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? @"C:\Program Files\LibreOffice\program\soffice.exe" : "libreoffice";
            this.LibreOfficePath = section.GetValue("LibreOffice", def);
        }
        public string[] AllowExtension { get; private set; }
        public string LibreOfficePath { get; private set; }
    }
}
